package org.huawei260.TiKu.ODsuanfa;

/**
 * @Author: qingle
 * @Date: 2024/10/28-16:11
 * @Description: 3409 【DP】2023B-代表团坐车
 * @version: 1.0
 */

import java.util.Arrays;
import java.util.Scanner;
public class B_2023B_3409__DP_代表团坐车 {

//	public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);

			Integer[] nums =
				Arrays.stream(sc.nextLine().split(",")).map(Integer::parseInt).toArray(Integer[]::new);

			int bag = Integer.parseInt(sc.nextLine());

			System.out.println(getResult(nums, bag));
		}

		private static int getResult(Integer[] nums, int bag) {
			int n = nums.length;

			int[] dp = new int[bag + 1];
			dp[0] = 1;

			for (int i = 1; i <= n; i++) {
				int num = nums[i - 1];
				for (int j = bag; j >= num; j--) {
					dp[j] = dp[j] + dp[j - num];
				}
			}

			return dp[bag];
		}
	}